home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / client / init.cs < prev    next >
Text File  |  2006-09-21  |  8KB  |  245 lines

  1. //-----------------------------------------------------------------------------
  2.  
  3. // Variables used by client scripts & code.  The ones marked with (c)
  4. // are accessed from code.  Variables preceeded by Pref:: are client
  5. // preferences and stored automatically in the ~/client/prefs.cs file
  6. // in between sessions.
  7. //
  8. //    (c) Client::MissionFile             Mission file name
  9. //    ( ) Client::Password                Password for server join
  10.  
  11. //    (?) Pref::Player::CurrentFOV
  12. //    (?) Pref::Player::DefaultFov
  13. //    ( ) Pref::Input::KeyboardTurnSpeed
  14.  
  15. //    (c) pref::Master[n]                 List of master servers
  16. //    (c) pref::Net::RegionMask     
  17. //    (c) pref::Client::ServerFavoriteCount
  18. //    (c) pref::Client::ServerFavorite[FavoriteCount]
  19. //    .. Many more prefs... need to finish this off
  20.  
  21. // Moves, not finished with this either...
  22. //    (c) firstPerson
  23. //    $mv*Action...
  24.  
  25. //-----------------------------------------------------------------------------
  26.  
  27. //-----------------------------------------------------------------------------
  28.  
  29. function initClient()
  30. {
  31.    echo("\n--------- Initializing MOD: Torque Demo Client ---------");
  32.  
  33.    // Make sure this variable reflects the correct state.
  34.    $Server::Dedicated = false;
  35.  
  36.    // Game information used to query the master server
  37.    $CLient::GameType = "";
  38.    $Client::GameTypeQuery = "";
  39.    $Client::MissionTypeQuery = "Any";
  40.  
  41.    //
  42.    exec("./ui/customProfiles.cs"); // override the base profiles if necessary
  43.  
  44.    // The common module provides basic client functionality
  45.    initBaseClient();
  46.  
  47.    // Always start up the shell in 800x600. If the pref is not set, then it
  48.    // will defaul to 800x600 in the platform code.
  49.    if ($Pref::Video::Resolution !$= "") {
  50.       $width = getWord($pref::Video::resolution,0);
  51.       if ($width < 800) {
  52.          $pref::Video::resolution = "800 600" SPC getWord($pref::Video::resolution,2);
  53.          echo("Forcing resolution to 800 x 600");
  54.       }
  55.    }
  56.    
  57.    // InitCanvas starts up the graphics system.
  58.    // The canvas needs to be constructed before the gui scripts are
  59.    // run because many of the controls assume the canvas exists at
  60.    // load time.
  61.    initCanvas("Torque Game Engine");
  62.  
  63.    /// Load client-side Audio Profiles/Descriptions
  64.    exec("./scripts/audioProfiles.cs");
  65.  
  66.    // Load up the Game GUIs
  67.    exec("./ui/defaultGameProfiles.cs");
  68.    exec("./ui/PlayGui.gui");
  69.    exec("./ui/FpsGui.gui");
  70.    exec("./ui/RacingGui.gui");
  71.    exec("./ui/SceneGui.gui");
  72. //   exec("./ui/PageGui.gui");  /// commented out to stop console error - file missing ***KCF*** 21-SEP-2006
  73.    exec("./ui/ChatHud.gui");
  74.    exec("./ui/playerList.gui");
  75.  
  76.    // Load up the shell GUIs
  77.    exec("./ui/overlayDlg.gui");
  78.    exec("./ui/mainMenuGui.gui");
  79.    exec("./ui/aboutDlg.gui");
  80.    exec("./ui/startMissionGui.gui");
  81.    exec("./ui/joinServerGui.gui");
  82.    exec("./ui/loadingGui.gui");
  83.    exec("./ui/endGameGui.gui");
  84.    exec("./ui/optionsDlg.gui");
  85.    exec("./ui/remapDlg.gui");
  86.    exec("./ui/StartupGui.gui");
  87.    exec("./ui/ProductGui.gui");
  88.  
  89.    // Demo page & scene gui
  90.    exec("./ui/MainMenuDlg.gui");
  91.    exec("./ui/overview_main.gui");
  92.    
  93.    exec("./ui/features/features_main.gui");
  94.    exec("./ui/features/features_script.gui");
  95.    exec("./ui/features/features_gui.gui");
  96.    exec("./ui/features/features_net.gui");
  97.    exec("./ui/features/features_render.gui");
  98.    exec("./ui/features/features_terrain.gui");
  99.    exec("./ui/features/features_interior.gui");
  100.    exec("./ui/features/features_mesh.gui");
  101.    exec("./ui/features/features_water.gui");
  102.    exec("./ui/features/features_sound.gui");
  103.    
  104.    exec("./ui/platform/platform_T2D.gui");
  105.    exec("./ui/platform/platform_TSE.gui");
  106.    exec("./ui/platform/platform_console.gui");
  107.    exec("./ui/platform/platform_TNL.gui");
  108.    
  109.    exec("./ui/tools/tools_main.gui");
  110.    exec("./ui/tools/tools_gui.gui");
  111.    exec("./ui/tools/tools_world.gui");
  112.    exec("./ui/tools/tools_terrain.gui");
  113.    exec("./ui/tools/tools_texture.gui");
  114.    exec("./ui/tools/tools_heightfield.gui");   
  115.    exec("./ui/tools/tools_showtool_pro.gui");
  116.    exec("./ui/tools/tools_rts_kit.gui");
  117.    exec("./ui/tools/tools_lighting_kit.gui");
  118.    exec("./ui/tools/tools_content_packs.gui");
  119.    exec("./ui/tools/tools_books_docs.gui");
  120.    
  121.    
  122.    exec("./ui/products/product_main.gui");
  123.    exec("./ui/products/product_tribes2.gui");
  124.    exec("./ui/products/product_hunting.gui");
  125.    exec("./ui/products/product_marbleblast.gui");
  126.    exec("./ui/products/product_thinktanks.gui");
  127.    exec("./ui/products/product_tenniscritters.gui");
  128.    exec("./ui/products/product_orbz.gui");   
  129.    exec("./ui/products/product_marbleblastultra.gui");   
  130.       
  131.    exec("./ui/testimonials/community.gui");   
  132.    exec("./ui/testimonials/testimonials_main.gui");
  133.    
  134.    exec("./ui/license/publishing.gui");
  135.    exec("./ui/license/license_main.gui");
  136.    exec("./ui/license/license_indie.gui");
  137.    exec("./ui/license/license_corp.gui");
  138. //   exec("./ui/license/license_other.gui");  // comment out to stop console error ***KCF*** 21-SEP-2006
  139.    
  140.    exec("./ui/garagegames/garagegames_main.gui");
  141.    
  142.    exec("./ui/theora/theora_main.gui");
  143.    
  144.    exec("./ui/AnimationSceneGui.gui");
  145.    exec("./ui/DetailSceneGui.gui");
  146.    exec("./ui/MountingSceneGui.gui");
  147.    
  148.    exec("./ui/DemoEditorAlert.gui");
  149.    
  150.    
  151.    // Client scripts
  152.    exec("./scripts/client.cs");
  153.    exec("./scripts/game.cs");
  154.    exec("./scripts/missionDownload.cs");
  155.    exec("./scripts/serverConnection.cs");
  156.    exec("./scripts/playerList.cs");
  157.    exec("./scripts/loadingGui.cs");
  158.    exec("./scripts/optionsDlg.cs");
  159.    exec("./scripts/chatHud.cs");
  160.    exec("./scripts/messageHud.cs");
  161.    exec("./scripts/mainMenuGui.cs");
  162.    exec("./scripts/playGui.cs");
  163.    exec("./scripts/fpsGui.cs");
  164.    exec("./scripts/racingGui.cs");
  165.    exec("./scripts/sceneGui.cs");
  166.    exec("./scripts/joinServerGui.cs");
  167.    exec("./scripts/startMissionGui.cs");
  168.    exec("./scripts/centerPrint.cs");
  169.    exec("./scripts/DemoEditorAlert.cs");
  170.    
  171.  
  172.    // load menu thread data
  173.    exec("./menu_threads.cs");
  174.  
  175.    // Default player key bindings
  176.    exec("./scripts/default.bind.cs");
  177.    exec("./config.cs");
  178.  
  179.    // Really shouldn't be starting the networking unless we are
  180.    // going to connect to a remote server, or host a multi-player
  181.    // game.
  182.    setNetPort(0);
  183.  
  184.    // Copy saved script prefs into C++ code.
  185.    setShadowDetailLevel( $pref::shadows );
  186.    setDefaultFov( $pref::Player::defaultFov );
  187.    setZoomSpeed( $pref::Player::zoomSpeed );
  188.  
  189.    // Start up the main menu... this is separated out into a 
  190.    // method for easier mod override.
  191.  
  192.    if ($JoinGameAddress !$= "") {
  193.       // If we are instantly connecting to an address, load the
  194.       // main menu then attempt the connect.
  195.       loadMainMenu();
  196.       connect($JoinGameAddress, "", $Pref::Player::Name);
  197.    }
  198.    else {
  199.       // Otherwise go to the splash screen.
  200.       Canvas.setCursor("DefaultCursor");
  201.       loadStartup();
  202.    }
  203. }
  204.  
  205.  
  206. //-----------------------------------------------------------------------------
  207.  
  208. function loadMainMenu()
  209. {
  210.    // Startup the client with the Main menu...
  211.    Canvas.setContent( MainMenuGui );
  212.    checkAudioInit();
  213.  
  214.    Canvas.setCursor("DefaultCursor");
  215. }
  216.  
  217. function loadFeatureMission()
  218. {
  219.    // Display the loading GUI
  220.    Canvas.setContent(LoadingGui);
  221.    LOAD_MapName.setText( "Creating Feature Game" );
  222.       LOAD_MapDescription.setText( "<font:Arial:16>Please wait while the feature game is started...");
  223.    Canvas.repaint();
  224.  
  225.    // Start up the server..
  226.    createServer("SinglePlayer", "demo/data/missions/features.mis");
  227.    %conn = new GameConnection(ServerConnection);
  228.    RootGroup.add(ServerConnection);
  229.    %conn.setConnectArgs($pref::Player::Name);
  230.    %conn.setJoinPassword($Client::Password);
  231.    %conn.connectLocal();
  232. }
  233.  
  234. function checkAudioInit()
  235. {
  236.    if($Audio::initFailed)
  237.    {
  238.       MessageBoxOK("Audio Initialization Failed", 
  239.          "The OpenAL audio system failed to initialize.  " @
  240.          "You can get the most recent OpenAL drivers <a:www.garagegames.com/docs/torque/gstarted/openal.html>here</a>.");
  241.    }
  242. }   
  243.  
  244.  
  245.